<html>
<head>
<#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
<#include "/WEB-INF/views/template/bootMainCss.ftl" parse=true encoding="utf-8">
    <#--<link href="${basePath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">-->
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css"
          rel="stylesheet">
    <style>
        .row {
            margin: 0;
        }

        .cash-info-tip {
            margin-right: 10px;
        }

        .search {
            float: left;
        }

        .shop-img {
            text-align: left;
            padding-left: 30px;
        }

        .shop-img img {
            float: left;
            margin-right: 10px;
        }

        .shop-img span {
            display: block;
        }

        .name {
            text-align: left;
            padding-left: 30px;
        }

        .name span {
            display: block;
        }

        #tbodyId {
            font-size: 13px;
        }

        #myTable thead {
            font-size: 14px;
        }

        #startTime form-control {
            width: 100%;
        }

        .form_datetime {
            float: left;
            width: 240px;
            margin-right: 10px;
        }

        #myForm .form-inline {
            float: right;
        }

        span .projectName {
            margin-right: 0;
        }
    </style>
</head>
<body>
<input type="hidden" id="pack_page" value="1">
<div class="panel panel-lzy">
    <div class="panel-body">
        <h5 class="tips-lzy">操作提示</h5>
        <ul class="tips-list-lzy">
            <li>◆&nbsp;<span>该页面显示了执行分利列表。</span></li>
        </ul>
    </div>
</div>

<div class="panel-body row">
    <form id="myForm" class="form-margin-right">
        <div class="form-group form-inline">
            <span>处理状态：</span>
            <select class="form-control required" name="status" id="status">
                <option value="">全部</option>
                <#list statusList as status>
                    <option value="${status.code?c}">${status.desc}</option>
                </#list>
            </select>
            <input type="text" class="form-control" id="key" placeholder="订单号">
            <button type="button" class="btn btn-primary btn-sm" onclick="search(1)">查询</button>
        </div>
        <#--<div class="form-group form-inline">-->
            <#--<input type="text" class="form-control" id="key" placeholder="订单号">-->
            <#--<button type="button" class="btn btn-primary btn-sm" onclick="search(1)">查询</button>-->
        <#--</div>-->
    </form>
</div>
<div class="panel-body row">

    <!-- 分页查询的地址-->
    <div class="panel-body panel-white">
        <div class="table-responsive">
            <table id="myTable"
                   class="table table-hover"
                   data-url="${basePath}/admin/profit/error/json"
                   data-pageSize="10,50,100" data-method="GET">
                <thead>
                <!-- 需要循环的字段  对应mapper文件-->
                <tr>
                    <th data-type="xuhao" width="4%">编号</th>
                    <th data-field="orderId" width="15%">订单号</th>
                    <th data-field="errorCode" width="15%">错误码</th>
                    <th data-field="errorMsg" width="30%">错误详情</span></th>
                    <th data-field="statusStr" width="10%">处理状态</th>
                    <th data-field="button" data-call="true">操作</th>
                </tr>
                </thead>
                <tbody id="tbodyId">

                </tbody>
            </table>
        </div>
        <!-- 分页条-->
        <div class="row">
            <div align="left" class="col-xs-6">
                <div class="input-group">
                    <span class="input-group-addon" id="pageCount"></span> <select
                        id="pageSize" onchange="search(1)" class="form-control"
                        style="width: 100px"></select>
                </div>
            </div>
            <div align="right" class="col-xs-6">
                <ul class="pagination" id="pagination"></ul>
            </div>
        </div>
    </div>

</div>
<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<script type="text/javascript"
        src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
        src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">

    //结束日期大于开始日期
    $(function () {
        $("#depart-box label input").each(function () {
            if (idArr.indexOf(parseInt($(this).val())) != "-1") {
                $(this).prop("checked", true)
            }
        })
    })
    function tableCallBack(data, id) {
        if (id == 'button') {//增加操作按钮
            //待处理和处理失败
            if (data.status != 1) {
                var count = 0;
                var _button = '<button type="button" class="btn btn-white btn-xs" onclick="dealProfitError(' + data.orderId + ');">执行分利</button> ';
                return _button;
            } else{
                return ""
            }
        } else {
            if (data[id] == null || data[id] == '') {
                return '';
            } else {
                return data[id];
            }
        }
    }

    function dealProfitError(orderId) {
        layer.confirm('是否确定此操作？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: 'PUT',
                url: '${basePath}/admin/profit/error/dealProfitError/' + orderId,
                success: function (data) {
                    var data = JSON.parse(data);
                    if (data.code == '0') {
                        layer.alert('处理成功!', {
                            icon: 6
                        }, function (index) {
                            layer.closeAll('dialog');
                            search(parseInt($('.active').attr('jp-data')));
                        });
                    } else {
                        layer.alert(data.desc, {
                            icon: 56
                        });
                    }
                }
            });
        });
    }

</script>
</body>
</html>